//  [9/4/2013 OMEGA] created

#ifndef _DUELASSEARCHIVEMODEL_H_
#define _DUELASSEARCHIVEMODEL_H_

#include <QAbstractItemModel>
#include "DuelAssECommon.h"

// make properties public for convenience.
class DAssEArchiveModelItem
{
public:
	QString		archiveType;
	QString		archiveName;
};

class DAssEArchiveModel : public QAbstractTableModel
{
	Q_OBJECT
public:
	enum 
	{
		ARCHIVETABLE_HEADER_TYPE	= 0,
		ARCHIVETABLE_HEADER_NAME	= 1
	};
	DAssEArchiveModel(DAssEArchiveView* parent);
	virtual ~DAssEArchiveModel();

	// use specified project to update data for viewing.
	void	reset(DAssEProject* proj);

	// append a archive to the end of the list. you don't need to call it
	// manually.
	void	appendArchive(DAssEArchive* arch);
	// remove an archive named archName, no guarantee for duplicated name.
	void	removeArchive(DAssEArchive* arch);

	DAssEArchiveModelItem*	getArchiveItem(int index);

	// override : QAbstractTableModel------------------------
	virtual int rowCount( const QModelIndex &parent = QModelIndex( ) ) const;
	// override : QAbstractTableModel------------------------
	virtual int columnCount( const QModelIndex &parent = QModelIndex( ) ) const;
	// override : QAbstractTabsleModel------------------------
	virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const;
	// override : QAbstractTableModel------------------------
	virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const;
	//////////////////////////////////////////////////////////////////////////
	Qt::ItemFlags flags(const QModelIndex &index) const;
	bool setData(const QModelIndex &index, const QVariant &value,
		int role = Qt::EditRole);
	bool insertRows(int position, int rows,
		const QModelIndex &parent = QModelIndex());
	bool removeRows(int position, int rows,
		const QModelIndex &parent = QModelIndex());

	//////////////////////////////////////////////////////////////////////////


protected:
	void				clearItems();
	DAssEArchiveView*		mParent;
	typedef	QList<DAssEArchiveModelItem*>		ArchiveModelItemList;	
	ArchiveModelItemList	mArchiveItems;
};



#endif